package com.huishao.api.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huishao.api.mapper.BlogMapper;
import com.huishao.api.entity.Blog;
import com.huishao.api.service.BlogService;
import org.springframework.stereotype.Service;
import com.huishao.api.common.PageResult;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huishao.api.utils.MybatisPlusUtil;

/**
 * (Blog)表服务实现类
 *
 * @author huishao
 * @since 2022-12-29 15:29:25
 */
@Service("blogService")
public class BlogServiceImpl extends ServiceImpl<BlogMapper, Blog> implements BlogService {

    @Override
    public PageResult getPage(Integer currentPage, Integer size, Blog blog) {
        Page<Blog> page = new Page<>(currentPage, size);

        QueryWrapper<Blog> queryWrapper = MybatisPlusUtil.queryWrapperBuilder(blog);

        this.page(page, queryWrapper);

        return new PageResult((int) page.getTotal(), page.getRecords());
    }
}

